<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 任意个数的参数计算
        const sum = (...args) => {
            let total = 0;
            args.forEach(value => total += value);
            return total;
        };
        var res1 = sum(10, 20);
        var res2 = sum(20, 50, 40);
        console.log(res1);
        console.log(res2);
        
    </script>
</body>

</html>